package com.heima.behavior.controller;

import com.heima.behavior.service.BehaviorService;
import com.heima.model.common.dtos.app.CollectionBehaviorDto;
import com.heima.model.common.dtos.app.LikesBehaviorDto;
import com.heima.model.common.dtos.app.ReadBehaviorDto;
import com.heima.model.common.dtos.app.UnLikesBehaviorDto;
import com.heima.model.common.dtos.common.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户行为相关接口
 */
@Api(value = "/api/v1/", tags = {"用户行为相关接口"})
@RestController
@RequestMapping("/api/v1/")
public class BehaviorController {
    @Autowired
    private BehaviorService behaviorService;

    /**
     * 点赞功能
     * @param dto
     * @return
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", dataType = "LikesBehaviorDto", name = "dto", value = "", required = true)
    })
    @ApiOperation(value = "点赞功能", notes = "点赞功能", httpMethod = "POST")
    @PostMapping("/likes_behavior")
    public ResponseResult likesBehavior(@RequestBody LikesBehaviorDto dto) {
        return behaviorService.likesBehavior(dto);
    }

    /**
     * 统计文章阅读量
     * @param dto
     * @return
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", dataType = "ReadBehaviorDto", name = "dto", value = "", required = true)
    })
    @ApiOperation(value = "统计文章阅读量", notes = "统计文章阅读量", httpMethod = "POST")
    @RequestMapping("/read_behavior")
    public ResponseResult readBehavior(@RequestBody ReadBehaviorDto dto) {
        return behaviorService.readBehavior(dto);
    }

    /**
     * 不喜欢功能
     * @param dto
     * @return
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", dataType = "UnLikesBehaviorDto", name = "dto", value = "", required = true)
    })
    @ApiOperation(value = "不喜欢功能", notes = "不喜欢功能", httpMethod = "POST")
    @PostMapping("/un_likes_behavior")
    public ResponseResult unlikesBehavior(@RequestBody UnLikesBehaviorDto dto){
        return behaviorService.unlikesBehavior(dto);
    }


}
